import URLSearchParams from 'url-search-params'
import queryString from 'query-string'
import homePage from './homePage'
import buyHistory from './buyHistory'
import myTeam from './myTeam'
import myPlayers from './myPlayers'
import diamondsDetail from './diamondsDetail'
import agentAudit from './agentAudit'
import agentApply from './agentApply'
import agentRun from './agentRun'
import myGroup from './myGroup'
global.queryString = queryString
global.URLSearchParams = URLSearchParams

const onHttps = window.location.href.match(/https/)
const config = {
  // pre: 'https://10.10.10.157:8191/game-lobby/',
  pre: onHttps ? 'https://c-c-a.jiahuagame.com/game-lobby' : 'https://c-c-a.jiahuagame.com/game-lobby',
  agentSystem: onHttps ? 'https://c-c-a.jiahuagame.com/lefantian-console/console/disp/' : 'https://c-c-a.jiahuagame.com/lefantian-console/console/disp/',
  // agentSystem: onHttps ? 'https://10.10.10.157:8191/lefantian-console/console/disp/' : 'https://10.10.10.157:8191/lefantian-console/console/disp/',
}

if (window.location.hostname.match(/(10\.10\.10|192\.168)/)) {
  // config.pre = 'http://10.10.10.155:8191/game-lobby'
  // config.agentSystem = onHttps ? 'http://10.10.10.155:8191/lefantian-console/console/disp/' : 'http://10.10.10.155:8191/lefantian-console/console/disp/'
  config.pre = 'http://192.168.1.155:8191/game-lobby'
  config.agentSystem = onHttps ? 'http://192.168.1.155:8191/lefantian-console/console/disp/' : 'http://192.168.1.155:8191/lefantian-console/console/disp/'

  // config.pre = onHttps ? 'https://c-c.jiahuagame.com/game-lobby' : 'https://c-c.jiahuagame.com/game-lobby'
  // config.agentSystem = onHttps ? 'https://c-c.jiahuagame.com/lefantian-console/console/disp/' : 'https://c-c.jiahuagame.com/lefantian-console/console/disp/'
}

// if (window.location.hostname.match(/lefantian/)) {
//   config.agentSystem = onHttps ? 'https://lefantian.jiahuagame.com/lefantian-console/console/disp/' : 'https://lefantian.jiahuagame.com/lefantian-console/console/disp/'
//   config.pre = onHttps ? 'https://lefantian.jiahuagame.com/game-lobby/' : 'https://lefantian.jiahuagame.com/game-lobby/'
// }
// if (window.location.hostname.match(/10.10.10/)) {
//   // config.pre = 'https://10.10.10.188:8191/game-lobby/'
//   // config.agentSystem = 'https://10.10.10.118:8191/lefantian-console/console/disp/'
//   config.pre = 'https://lefantian.jiahuagame.com/game-lobby/'
//   config.agentSystem = 'https://lefantian.jiahuagame.com/lefantian-console/console/disp/'
// }

// if (window.location.hostname.match(/10.10.10/)) {
//   // config.agentSystem = 'https://10.10.10.114:8191/game-lobby/'
//   // config.pre = 'https://c-c-a.jiahuagame.com/lefantian-console/console/disp/'
//   // config.pre = 'https://lefantian.jiahuagame.com/game-lobby/'
//   // config.agentSystem = 'https://lefantian.jiahuagame.com/lefantian-console/console/disp/'
// } else if (window.location.hostname.match(/lefantian/)) {
//   config.agentSystem = 'https://lefantian.jiahuagame.com/lefantian-console/console/disp/'
//   config.pre = 'https://lefantian.jiahuagame.com/game-lobby/'
// } else {
//   config.agentSystem = 'https://c-c-a.jiahuagame.com/lefantian-console/console/disp/'
//   config.pre = 'https://c-c-a.jiahuagame.com/game-lobby/'
// }

const api = {
  homePage: homePage(config),
  buyHistory: buyHistory(config),
  diamondsDetail: diamondsDetail(config),
  myTeam: myTeam(config),
  myPlayers: myPlayers(config),
  agentAudit: agentAudit(config),
  agentApply: agentApply(config),
  group: myGroup(config),
  agentRun: agentRun(config),
}

export default api